package cl.whyem.testsutilityproject.guava.functions;

import com.google.common.base.CharMatcher;
import com.google.common.base.Function;
import java.util.ArrayList;

public class MyReplaceFrom implements Function<String[], StringBuffer> {

    public StringBuffer apply(String[] f) {
        if (f.length == 3) {
            String replaced = CharMatcher.anyOf(f[0]).replaceFrom(f[1], f[2]);
            return new StringBuffer(replaced);
        }
        return new StringBuffer("");
    }

    public static ArrayList<String[]> getReplaceParameters(final String searchString, final String text, final String replacementString) {
        return new ArrayList<String[]>() {
            {
                add(new String[]{searchString, text, replacementString});
            }
        };
    }
}
